<?php
require 'isok.php';
require 'dbcon.php';
require 'database.php';
$page=isset($_GET['page'])?$_GET['page']:1;
$pagesize=15;
$num=getnumcom();
$maxpage=ceil($num/$pagesize);
$postdata=getpagecom($page,$pagesize);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Comments &laquo; Admin</title>
  <link rel="stylesheet" href="css/bootstrap.css">
  <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.css">
  <link rel="stylesheet" href="css/nprogress.css">
  <link rel="stylesheet" href="css/admin.css">
  <script src="js/nprogress.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
    <nav class="navbar">
      <button class="btn btn-default navbar-btn fa fa-bars"></button>
      <ul class="nav navbar-nav navbar-right">
          <li><a href="profile.php"><i class="fa fa-user"></i>个人中心</a></li>
          <li><a href="login.php"><i class="fa fa-sign-out"></i>退出</a></li>
      </ul>
    </nav>
    <div class="container-fluid">
      <div class="page-title">
        <h1>所有评论</h1>
      </div>
      <!-- 有错误信息时展示 -->
      <!-- <div class="alert alert-danger">
        <strong>错误！</strong>发生XXX错误
      </div> -->
      <div class="page-action">
        <!-- show when multiple checked -->
        <div class="btn-batch" style="display: none">
          <button class="btn btn-info btn-sm">批量批准</button>
          <button class="btn btn-warning btn-sm">批量拒绝</button>
          <button class="btn btn-danger btn-sm">批量删除</button>
        </div>
         <ul class="pagination pagination-sm pull-right">
          <li><a href="">当前第<?php echo $page;?>页/共<?php echo $maxpage;?>页</a></li>  
          <li><a href="?page=1">首页</a></li>
          <li><a href="?page=<?php echo $page==1?1:$page-1;?>">上一页</a></li>         
          <li><a href="?page=<?php echo $page==$maxpage?$maxpage:$page+1;?>">下一页</a></li>
          <li><a href="?page=<?php echo $maxpage?>">尾页</a></li>
        </ul>
      </div>
      <table class="table table-striped table-bordered table-hover">
        <thead>
          <tr>
            <th class="text-center" width="40"><input type="checkbox"></th>
            <th>作者</th>
            <th>评论</th>
            <th>评论在</th>
            <th>提交于</th>
            <th>状态</th>
            <th class="text-center" width="100">操作</th>
          </tr>
        </thead>
        <tbody>
            <?php 
            foreach ($bbsdata as $v)
                {
            ?>
            <tr class="danger">
            <td class="text-center"><input type="checkbox"></td>
            <td><?php echo $v['author']?></td>
            <td><?php echo $v['content']?></td>
            <td><?php echo $v['title']?></td>
            <td><?php echo $v['created']?></td>
            <td>
                 <?php 
                switch ($v['status'])
                {
                    case 'rejected':
                    echo '拒绝';
                    break;
                    case 'approved':
                    echo '准许';
                    break;
                    case 'trashed':
                    echo '回收站';
                    break;
                    default:
                    echo '待审核';
                }
                ?>
            </td>
            <td class="text-center">
              <a href="post-add.php" class="btn btn-info btn-xs">批准</a>
              <a href="javascript:;" class="btn btn-danger btn-xs" onclick="if(confirm('确定删除吗？')) location.href='commentsdel.php?id=<?php echo $v['id']?>'">删除</a>
            </td>
          </tr>
           <?php
             }
           ?>
        </tbody>
      </table>
    </div>
  </div>

  <div class="aside">
    <div class="profile">
      <img class="avatar" src="<?php echo $userinfo['avatar']?>">
        <h3 class="name"><?php echo $userinfo['nickname']?></h3>
    </div>
    <ul class="nav">
      <li>
        <a href="index.php"><i class="fa fa-dashboard"></i>仪表盘</a>
      </li>
      <li>
        <a href="#menu-posts" class="collapsed" data-toggle="collapse">
          <i class="fa fa-thumb-tack"></i>文章<i class="fa fa-angle-right"></i>
        </a>
        <ul id="menu-posts" class="collapse">
          <li><a href="isposts.php">所有文章</a></li>
          <li><a href="ispost-add.php">写文章</a></li>
          <li><a href="iscategories.php">分类目录</a></li>
        </ul>
      </li>
      <li class="active">
        <a href="iscomments.php"><i class="fa fa-comments"></i>评论</a>
      </li>
      <li>
        <a href="isusers.php"><i class="fa fa-users"></i>用户</a>
      </li>
      <li>
        <a href="#menu-settings" class="collapsed" data-toggle="collapse">
          <i class="fa fa-cogs"></i>设置<i class="fa fa-angle-right"></i>
        </a>
        <ul id="menu-settings" class="collapse">
          <li><a href="isnav-menus.php">导航菜单</a></li>
          <li><a href="slides.php">图片轮播</a></li>
          <li><a href="issettings.php">网站设置</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <script src="js/jquery.js"></script>
  <script src="js/bootstrap.js"></script>
  <script>NProgress.done()</script>
</body>
</html>
